package com.rulesConstraint;

import com.pojo.PersonP;
import com.pojo.School;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

/**
 * @author Administrator
 */
public class RulesConstraint {

    public static void main(String[] args) {
        KieServices kieServices = KieServices.Factory.get();
        KieContainer kc = kieServices.getKieClasspathContainer();
        KieSession ks = kc.newKieSession("contains");
        PersonP p = new PersonP();
        p.setName("张三");
        p.setAge(30);
        p.setClassName("一班");
        School school = new School();
        school.setClassName("一班");
        ks.insert(p);
        ks.insert(school);

        int count = ks.fireAllRules();
        System.out.println("总执行了" + count + "条规则");
        ks.dispose();
    }
}
